# coding=utf-8
import time

import allure
import yaml
from selenium import webdriver

from homework_web_po.base_page.base_page import BasePage
from homework_web_po.po.home_page import HomePage


class LoginPage(BasePage):

    _URL = "https://work.weixin.qq.com/wework_admin/loginpage_wx"

    # 通过cookies登陆
    @allure.step("登陆成功，进入首页")
    def login(self):
        self.open_url(self._URL)
        with open("../data/cookies.yaml","r",encoding="utf-8") as file:
            cookies = yaml.safe_load(file)
        for cookie in cookies:
            self.driver.add_cookie(cookie)
        self.driver.refresh()
        time.sleep(2)
        print("登陆成功，进入首页")
        return HomePage(self.driver)



# if __name__ == '__main__':
#     login = LoginPage()
#     login.login()

